package icu.lookyousmileface.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author shenj
 * @title: ServerChannelInitializer
 * @projectName NettyPro
 * @date 2020/12/4 14:34
 */
public class ServerChannelInitializer extends ChannelInitializer<SocketChannel> {
    /**
     * @author shenj
     * @title: initChannel
     * @date 2020/12/4  14:36
     * 通道初始化
     */
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        ChannelPipeline pipeline = ch.pipeline();
        //HttpServerCodec---》 http编解码对象
        pipeline.addLast("MyHttpServerCodec",new HttpServerCodec());
        pipeline.addLast("MyServerChannelInitializer",new ServerHandler());
        System.out.println("Ok");
    }
}
